package com.gisocn.onemap.ui.adapter;

import android.text.Editable;
import android.text.TextWatcher;
import android.util.SparseBooleanArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import butterknife.internal.Utils;
import com.gisocn.onemap.interfaces.OnGroupItemCheckListener;
import com.gisocn.onemap.interfaces.OnItemClickEditextListener;
import com.gisocn.onemap.interfaces.OnItemClickListener;
import com.gisocn.onemap.model.QueryWhere;
import com.gisocn.onemap.sgzx.R;
import java.util.ArrayList;

/* loaded from: classes2.dex */
public class QueryWhereAdapter extends RecyclerView.Adapter<ViewHolder> {
    private ArrayList<QueryWhere> queryWheres;
    private SparseBooleanArray mCheckStates = new SparseBooleanArray();
    private final boolean mBoundWatcher = true;
    private OnItemClickListener onItemClickListener = null;
    private OnGroupItemCheckListener onItemClickListener2 = null;
    private OnItemClickListener onItemClickListener1 = null;
    private OnItemClickEditextListener onItemClickEditextListener = null;

    /* loaded from: classes2.dex */
    public class ViewHolder_ViewBinding implements Unbinder {
        private ViewHolder target;

        public ViewHolder_ViewBinding(ViewHolder viewHolder, View view) {
            this.target = viewHolder;
            viewHolder.checkboxName = (CheckBox) Utils.findRequiredViewAsType(view, R.id.checkbox_name, "field 'checkboxName'", CheckBox.class);
            viewHolder.tvSymbol = (TextView) Utils.findRequiredViewAsType(view, R.id.tv_symbol, "field 'tvSymbol'", TextView.class);
            viewHolder.etWhere1 = (EditText) Utils.findRequiredViewAsType(view, R.id.et_where1, "field 'etWhere1'", EditText.class);
            viewHolder.etWhere2 = (EditText) Utils.findRequiredViewAsType(view, R.id.et_where2, "field 'etWhere2'", EditText.class);
            viewHolder.tvWhere = (TextView) Utils.findRequiredViewAsType(view, R.id.tv_where, "field 'tvWhere'", TextView.class);
        }

        @Override // butterknife.Unbinder
        public void unbind() {
            ViewHolder viewHolder = this.target;
            if (viewHolder == null) {
                throw new IllegalStateException("Bindings already cleared.");
            }
            this.target = null;
            viewHolder.checkboxName = null;
            viewHolder.tvSymbol = null;
            viewHolder.etWhere1 = null;
            viewHolder.etWhere2 = null;
            viewHolder.tvWhere = null;
        }
    }

    public QueryWhereAdapter(ArrayList<QueryWhere> arrayList) {
        this.queryWheres = arrayList;
    }

    public void setOnItemClickSymbolListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public void setOnItemClickCheckListener(OnGroupItemCheckListener onGroupItemCheckListener) {
        this.onItemClickListener2 = onGroupItemCheckListener;
    }

    public void setOnItemClickWhereListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener1 = onItemClickListener;
    }

    public void setOnItemClickEditextListener(OnItemClickEditextListener onItemClickEditextListener) {
        this.onItemClickEditextListener = onItemClickEditextListener;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        return new ViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_query_where, viewGroup, false));
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public void onBindViewHolder(final ViewHolder viewHolder, final int i) {
        viewHolder.checkboxName.setText(this.queryWheres.get(i).getQueryField().getAliasName());
        if (this.queryWheres.get(i).getSyboml() == null) {
            if (this.queryWheres.get(i).getQueryField().getDefaultOperator() != null) {
                TextView textView = viewHolder.tvSymbol;
                textView.setText(this.queryWheres.get(i).getQueryField().getDefaultOperator() + "");
            } else {
                viewHolder.tvSymbol.setText("like");
            }
        } else {
            viewHolder.tvSymbol.setText(this.queryWheres.get(i).getSyboml());
        }
        if (this.queryWheres.get(i).getWhereOne() != null) {
            viewHolder.etWhere1.setText(this.queryWheres.get(i).getWhereOne());
        } else {
            viewHolder.etWhere1.setText("");
        }
        viewHolder.tvSymbol.setOnClickListener(new View.OnClickListener() { // from class: com.gisocn.onemap.ui.adapter.QueryWhereAdapter.1
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                if (QueryWhereAdapter.this.onItemClickListener != null) {
                    QueryWhereAdapter.this.onItemClickListener.onItemClick(view, i);
                }
            }
        });
        viewHolder.tvWhere.setOnClickListener(new View.OnClickListener() { // from class: com.gisocn.onemap.ui.adapter.QueryWhereAdapter.2
            @Override // android.view.View.OnClickListener
            public void onClick(View view) {
                if (QueryWhereAdapter.this.onItemClickListener1 != null) {
                    QueryWhereAdapter.this.onItemClickListener1.onItemClick(view, i);
                }
            }
        });
        viewHolder.checkboxName.setChecked(this.queryWheres.get(i).isCheck());
        viewHolder.checkboxName.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // from class: com.gisocn.onemap.ui.adapter.QueryWhereAdapter.3
            @Override // android.widget.CompoundButton.OnCheckedChangeListener
            public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                if (QueryWhereAdapter.this.onItemClickListener2 != null) {
                    QueryWhereAdapter.this.onItemClickListener2.onItemClick(compoundButton, viewHolder.getAdapterPosition(), z);
                }
            }
        });
        if (this.queryWheres.get(i).getSyboml() != null && this.queryWheres.get(i).getSyboml().equals("[,]")) {
            viewHolder.etWhere2.setVisibility(0);
        } else {
            viewHolder.etWhere2.setVisibility(8);
        }
        if (viewHolder.etWhere1.getTag() == null || !((Boolean) viewHolder.etWhere1.getTag()).booleanValue()) {
            viewHolder.etWhere1.addTextChangedListener(new TextWatcher() { // from class: com.gisocn.onemap.ui.adapter.QueryWhereAdapter.4
                @Override // android.text.TextWatcher
                public void beforeTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
                }

                @Override // android.text.TextWatcher
                public void onTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
                }

                @Override // android.text.TextWatcher
                public void afterTextChanged(Editable editable) {
                    if (QueryWhereAdapter.this.onItemClickEditextListener != null) {
                        QueryWhereAdapter.this.onItemClickEditextListener.onItemClick(viewHolder.getAdapterPosition(), editable.toString(), true);
                    }
                }
            });
            viewHolder.etWhere1.setTag(true);
            if (viewHolder.etWhere2.getTag() == null || !((Boolean) viewHolder.etWhere2.getTag()).booleanValue()) {
                viewHolder.etWhere2.addTextChangedListener(new TextWatcher() { // from class: com.gisocn.onemap.ui.adapter.QueryWhereAdapter.5
                    @Override // android.text.TextWatcher
                    public void beforeTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
                    }

                    @Override // android.text.TextWatcher
                    public void onTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
                    }

                    @Override // android.text.TextWatcher
                    public void afterTextChanged(Editable editable) {
                        if (QueryWhereAdapter.this.onItemClickEditextListener != null) {
                            QueryWhereAdapter.this.onItemClickEditextListener.onItemClick(viewHolder.getAdapterPosition(), editable.toString(), false);
                        }
                    }
                });
                viewHolder.etWhere2.setTag(true);
            }
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public int getItemCount() {
        return this.queryWheres.size();
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes2.dex */
    public static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.checkbox_name)
        CheckBox checkboxName;
        @BindView(R.id.et_where1)
        EditText etWhere1;
        @BindView(R.id.et_where2)
        EditText etWhere2;
        @BindView(R.id.tv_symbol)
        TextView tvSymbol;
        @BindView(R.id.tv_where)
        TextView tvWhere;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
